home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / WCTUNITS / MOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-03  |  26KB  |  821 lines

  1. UNIT Mouse;
  2. { Mouse unit for Turbo Pascal.
  3.   The comments in this unit were basically copied directly
  4.   from the Advanced MS Dos Programing book, the section on
  5.   the Microsoft Mouse Driver, which was the source of all
  6.   the mouse interrupt functions and their parameters.
  7. }
  8.  
  9.  
  10. INTERFACE
  11.  
  12. USES
  13.   Dos;
  14.  
  15. CONST
  16.   LeftButton = 1;
  17.   RightButton = 2;
  18.   CenterButton = 4;
  19.   AnyButton = 7;
  20.  
  21. var
  22.   mouseon: boolean;
  23.  
  24. PROCEDURE InitMouse(VAR Buttons : word; VAR Err : boolean);
  25. { Initializes the mouse driver.
  26.   Call:    nothing
  27.   Returns: Buttons = number of mouse buttons
  28.        Err     = false if mouse support is available, true otherwise
  29.   Note:    * After a call to this function the driver is initialized to the
  30.     following state:
  31.     - Mouse pointer at screen center and hidden.
  32.     - Display page is set to zero.
  33.     - Mouse pointer shape set to default arrow shape in graphics modes,
  34.     or reverse block in text modes.
  35.     - User mouse event handlers are disabled.
  36.     - Light pen emulation enabled.
  37.     - Mouse sensitivity set to default vales (see SetMouseSense)
  38.     - Pointer limits set to entire screen.
  39.   - Set mouseon to false
  40. }
  41.  
  42. PROCEDURE Showmouse;
  43. { Displays the mouse pointer, and cancels any pointer exclusion area. }
  44.  
  45. PROCEDURE Hidemouse;
  46. { Removes the mouse pointer from the screen, but continues to track the
  47.   position of the mouse. }
  48.  
  49. FUNCTION ButtonPressed(Mask : word) : boolean;
  50. { Returns a true value if the specified button(s) is pressed.
  51.   Call:    Mask = bit mask of desired button(s)
  52.     bit(s)  Significance(if set)
  53.     0       left button
  54.     1       right button
  55.     2       center button
  56.     3-15    reserved(0)
  57.   : True is button is pressed, false otherwise.
  58.   Note:    * The constants LeftButton, RightButton, CenterButton, and
  59.     AnyButton can be used for the bit masking.  They equal 1, 2,
  60.     4, and 7 respectivly.
  61. }
  62.  
  63. PROCEDURE GetMousePosition(VAR Buttons, Horiz, Vert : word);
  64. { Returns the current mouse button status and pointer position.
  65.   Call:    nothing
  66.   Returns: Buttons = mouse button status
  67.     Horiz   = horizontal (X) coordinate
  68.     Vert    = vertical (Y) coordinate
  69.   Note:    * Coordinates are in pixels regardless of the current display mode.
  70.     Position (0,0) is the upper left corner of the screen.
  71. }
  72.  
  73. FUNCTION MouseIn(x1,y1,x2,y2: word):boolean;
  74. { Returns true if mouse is within rectangle with upper-left
  75.   corner (x1,y1) and lower-right corner (x2,y2).
  76. }
  77.  
  78. PROCEDURE SetPointerPosition(Horiz, Vert : word);
  79. { Set the position of the pointer.  The pointer is displayed in the new
  80.   position unless it has been hidden using HidePointer or it is an exclusion
  81.   area defined by SetPointerExcl.
  82.   Call:    Horiz = horizontal (X) coordinate
  83.     Vert  = vertical (Y) coordinate
  84.   Returns: nothing
  85.   Notes:   * Coordinates are in pixels regardless of the current display mode.
  86.     Position (0,0) is the upper left corner of the screen.
  87.     * The position is adjusted if necessary to lie within the pointer
  88.     limits set by SetLimits.
  89. }
  90. PROCEDURE GetPressInfo(Button : word;
  91.                VAR Stat, Count, Horiz, Vert : word);
  92. { Returns the current status of all mouse buttons, and the number of presses
  93.   and position of the last press for a specifed mouse button since the last
  94.   call to this procedure for that button.  The press counter for the button
  95.   is reset to zero.
  96.   Call:    Button = button identifier
  97.     0 = left button
  98.     1 = right button
  99.     2 = center button
  100.   : Stat   = button status
  101.     bit(s)  Significance(if set)
  102.     0       left button is down
  103.     1       right button is down
  104.     2       center button is down
  105.     3-15    reserved(0)
  106.     Count  = button press counter
  107.     Horiz  = horizontal (X) coordinate of last button press
  108.     Vert   = vertical (Y) coordinate of last button press
  109. }
  110. PROCEDURE GetReleaseInfo(Button : word;
  111.              VAR Stat, Count, Horiz, Vert : word);
  112. { Returns the current status of all mouse buttons, and the number of releases
  113.   and position of the last release for a specifed mouse button since the last
  114.   call to this procedure for that button.  The release counter for the button
  115.   is reset to zero.
  116.   Call:    Button = button identifier
  117.     0 = left button
  118.     1 = right button
  119.     2 = center button
  120.   Returns: Stat   = button status
  121.     bit(s)  Significance(if set)
  122.     0       left button is down
  123.     1       right button is down
  124.     2       center button is down
  125.     3-15    reserved(0)
  126.     Count  = button release counter
  127.     Horiz  = horizontal (X) coordinate of last button release
  128.     Vert   = vertical (Y) coordinate of last button release
  129. }
  130. PROCEDURE SetLimits(HorMin, HorMax, VerMin, VerMax : word);
  131. { Limits the mouse pointer to stay within a certian area.
  132.   Call:    HorMin = Minimum horizontal (X) coordinate
  133.     HorMax = Maximum horizontal (X) coordinate
  134.     VerMin = Minimum vertical (Y) coordinate
  135.     VerMax = Maximum vertical (Y) coordinate
  136.   Returns: nothing
  137.   Note:    * If both HorMin and HorMax are zero then then the previous
  138.     horizontal limits remain unchanged; the same is true for
  139.     VerMin and VerMax.
  140. }
  141. PROCEDURE SetPointerShape(Horiz, Vert : word; Buffer : pointer);
  142. { Defines the shape, color, and hot spot of the pointer in graphics modes.
  143.   Call:    Horiz  = hot spot offset from the left
  144.     Vert   = hot spot offset from the top
  145.     Buffer = pointer to mouse pointer image buffer
  146.   Returns: nothing
  147.   Note:    * The pointer image buffer is 64 bytes long.  The first 32 bytes
  148.     contain a bit mask which is ANDed with the screen image, and the
  149.     remaining 32 bytes are then XORed with the screen image.
  150.        * The hot spot is relative to the upper left corner of the pointer
  151.          image, and each offset must be in the range -16 to 16.  In display
  152.          modes 4 and 5, the horizontal offset must be an even number.
  153. }
  154. PROCEDURE SetTextPointer(PtrTyp, AND_Str, XOR_End : word);
  155. { Defines the shape and attributes of the mouse pointer in text modes.
  156.   Call:    PtrTyp  = pointer type
  157.              0 = software cursor
  158.              1 = hardware cursor
  159.        AND_Str = AND mask value (if PtrTyp = 0) or starting line for
  160.              cursor (if PtrTyp = 1)
  161.        XOR_End = XOR mask value (if PtrTyp = 0) or ending line for
  162.              cursor (if PtrTyp = 1)
  163.   Returns: nothing
  164.   Notes:   * If the software text cursor is selected, the masks in AND_Str and
  165.          XOR_End are mapped as follows:
  166.          Bit(s)   Significance
  167.          0-7      character code
  168.          8-10     foreground color
  169.          11       intensity
  170.          12-14    background color
  171.          15       blink
  172.          For Example, the following call would yeild a software cursor
  173.          that inverts the foreground and background colors:
  174.          SetTextPointer(0, $77FF, $7700);
  175.        * When the hardware text cursor is selected, the values in AND_Str
  176.          and XOR_End are the starting and ending lines for the blinking
  177.          cursor generated by the video adapter.  The maximum scan line
  178.          depends on the type of adapter and the current display mode.
  179. }
  180. PROCEDURE GetMotionCount(VAR Horiz, Vert : word);
  181. { Returns the net mouse displacement since the last call to this procedure.
  182.   The returned value is in mickeys; a positive number indicates travel to the
  183.   right or downwards, a negative number indicates travel to the left or
  184.   upwards.  One mickey represents approximately 1/200 of an inch of mouse
  185.   movement.
  186.   Call:    nothing
  187.   Returns: Horiz = horizontal (X) mickey count
  188.        Vert  = vertical (Y) mickey count
  189. }
  190. PROCEDURE SetEventHandler(EventMask : word; Handler : pointer);
  191. { Sets the address and event mask for an application program's mouse event
  192.   handler.  The handler is called by the mouse drvier whenever the specifed
  193.   mouse events occur.
  194.   Call:    EventMask = event mask
  195.                Bit(s)  Significance(if set)
  196.                0       mouse movement
  197.                1       left button pressed
  198.                2       left button released
  199.                3       right button pressed
  200.                4       right button released
  201.                5       center button pressed
  202.                6       center button released
  203.                7-15    reserved(0)
  204.        Handler   = Pointer to the handler procedure
  205.   Returns: nothing
  206.   Notes:   * The user-defined handler is entered from the mouse driver by a
  207.          far call with the registers set up as follows:
  208.          AX       mouse event flags (see event mask)
  209.          BX       button state
  210.               Bit(s)  Significance(if set)
  211.               0       left button is down
  212.               1       right button is down
  213.               2       center button is down
  214.               3-15    reserved(0)
  215.          CX       horizontal (X) pointer coordinate
  216.          DX       vertical (Y) pointer coordinate
  217.          SI       last raw vertical mickey count
  218.          DI       last raw horizontal mickey count
  219.          DS       mouse driver data segment
  220.        * If an event does not generate a call to the user-defined handler
  221.          because its bit is not set in the event mask, it is still reported
  222.          in the event falgs during calls to the handler for events which
  223.          are enabled.
  224. }
  225. PROCEDURE SetLightPen(On_Off : word);
  226. { Turns the light pen emulation by the mouse driver for IBM BASIC on or off.
  227.   A "pen down" condition is created by pressing the left and right mouse
  228.   buttons simultaneosly.
  229.   Call:    On_Off = true to enable or false to disable emulation.
  230.   Returns: nothing
  231. }
  232. PROCEDURE SetPointerExcl(HorMin, VerMin, HorMax, VerMax : word);
  233. { Defines an exclusion area for the mouse pointer.  When the mouse pointer
  234.   lies within the specified area, it is not displayed.
  235.   Call:    HorMin = upper left X coordinate
  236.        VerMin = upper left Y coordinate
  237.        HorMax = lower right X coordinate
  238.        VerMax = lower right Y coordinate
  239.   Returns: nothing
  240.   Note:    *  The exclusion area is replaced by another call to this
  241.           procdure or cancelled by InitMouse and ShowPointer.
  242. }
  243. PROCEDURE SwapEventHandlers(VAR Mask : word; VAR Buffer : pointer);
  244. { Set the address and event mask for an application program's mouse event
  245.   handler and returns the address and event mask for the previous handler.
  246.   The newly installed handler is called by the mouse driver whenever the
  247.   specified mouse events occur.
  248.   Call:    Mask    = event mask
  249.              Bit(s)  Significance(if set)
  250.              0       mouse movement
  251.              1       left button pressed
  252.              2       left button released
  253.              3       right button pressed
  254.              4       right button released
  255.              5       center button pressed
  256.              6       center button released
  257.              7-15    reserved(0)
  258.        Handler = Pointer to the handler procedure
  259.   Returns: Mask    = previous event mask
  260.        Handler = pointer to previous handler
  261.   Notes:   * The notes for SetEventHandler describe the information passed to
  262.          the user-defined event handler.  Also see SetAltEventHandler.
  263.        * Calls to the event handler are disabled with InitMouse or by
  264.          setting an event mask of zero.
  265. }
  266. FUNCTION GetSaveStateSize : word;
  267. { Returns the size of the buffer required to store the current state of the
  268.   mouse driver.
  269.   Note:    * also see SaveDrvrState and RestoreDrvrState.
  270. }
  271. PROCEDURE SaveDrvrState(Buffer : pointer);
  272. { Saves the mouse driver state in a user buffer.  THe minimum size for the
  273.   buffer must be determined by GetSaveStateSize.
  274.   Call:    Buffer = pointer to the user defined buffer.
  275.   Returns: nothing
  276.   Note:    * Use this procedure before executing a child program (Exec), in
  277.          case the child aslo uses the mouse. After the Exec call, restore
  278.          the previous mouse driver state using RestoreDrvrState.
  279. }
  280. PROCEDURE RestoreDrvrState(Buffer : pointer);
  281. { Restores the mouse driver state from a user buffer.
  282.   Call:    Buffer = pointer to the user defined buffer.
  283.   Returns: nothing
  284.   Note:    * The mouse driver state must have been previously saved into the
  285.          same buffer with SaveDrvrState.  The format of the data in the
  286.          buffer in undocumented and subject to change.
  287. }
  288. PROCEDURE SetAltEventHandler(Mask : word; Handler : pointer; VAR Err: boolean);
  289. { Sets the address and event mask for an application program's mouse event
  290.   handler.  As many as three handlers with distinct event masks can be
  291.   registered with this function.  When an event occurs that matches one of the
  292.   masks, the corresponding handler is called by the mouse driver.
  293.   Call:    Mask    = event mask
  294.              Bit(s)  Significance(if set)
  295.              0       mouse movement
  296.              1       left button pressed
  297.              2       left button released
  298.              3       right button pressed
  299.              4       right button released
  300.              5       Shift key pressed during button press or release
  301.              6       Ctrl key pressed during button press or release
  302.              7       Alt key pressed during button press or release
  303.              8-15    reserved(0)
  304.        Handler = Pointer to the handler procedure
  305.   Returns: Err     = false if successful, true otherwise
  306.   Notes:   * When this procedure is called, at least one of the bits 5, 6, and
  307.          7 must be set in Mask.
  308.        * The user-defined handler is entered from the mouse driver by a
  309.          far call with the registers set up as follows:
  310.          AX       mouse event flags (see event mask)
  311.          BX       button state
  312.               Bit(s)  Significance(if set)
  313.               0       left button is down
  314.               1       right button is down
  315.               2       center button is down
  316.               3-15    reserved(0)
  317.          CX       horizontal (X) pointer coordinate
  318.          DX       vertical (Y) pointer coordinate
  319.          SI       last raw vertical mickey count
  320.          DI       last raw horizontal mickey count
  321.          DS       mouse driver data segment
  322.        * If an event does not generate a call to the user-defined handler
  323.          because its bit is not set in the event mask, it is still reported
  324.          in the event falgs during calls to the handler for events which
  325.          are enabled.
  326.        * Calls to the handler are disabled with InitMouse.
  327.        * Also see SetEventHandler and SwapEventHandlers.
  328. }
  329. PROCEDURE GetAltEventAdrs(VAR Mask : word; VAR Handler : pointer;
  330.               VAR Err : boolean);
  331. { Returns the address for the mouse event handler matching the specified
  332.   event mask.
  333.   Call:    Mask    = event mask
  334.              (see SetAltEventHandler)
  335.   Returns: Mask    = event mask
  336.        Handler = pointer to the alternate event handler
  337.        Err     = false if successful, true if not successful (no handler
  338.              installed or event mask does not match any installed
  339.              handler.
  340.   Note:    * SetAltEventHandler allows as many as three event handler with
  341.          distinct event masks to be installed.  This procedure can be
  342.          called to search for a handler that matches a specific event, so
  343.          that it can be replaced or disabled.
  344. }
  345. PROCEDURE SetMouseSense(Horiz, Vert, Double : word);
  346. { Set the number of mickeys per 8 pixels for horizontal and vertical mouse
  347.   motion and the threshold speed for doubleing pointer motion on the screen.
  348.   One mickey represents approximately 1/200 of an inch of mouse travel.
  349.   Call:    Horiz  = horizontal mickeys (1-32,767; default=8)
  350.        Vert   = vertical mickeys (1-32,767; default=16)
  351.        Double = double speed threshold in mickeys/second (default=64);
  352.   Returns: nothing
  353. }
  354. PROCEDURE GetMouseSense(VAR Horiz, Vert, Double : word);
  355. { Return the current mickeys to pixels ratios for vertical and horizontal
  356.   screen movement and the threshold speed for doubling of pointer motion.
  357.   Call:    nothing
  358.   Returns: Horiz  = horizontal mickeys (1-32,767; default=8)
  359.        Vert   = vertical mickeys (1-32,767; default=16)
  360.        Double = double speed threshold in mickeys/second (default=64);
  361. }
  362. PROCEDURE SetMouseIntr(Flags : word);
  363. { Sets the rate at which the mouse driver polls the status of the mouse.
  364.   Faster rates provide better resolution in graphics mode but may degrade
  365.   the performance of application programs.
  366.   Call:    Flags = interrupt rate flags
  367.            Bit(s)    Significance(if set)
  368.            0         no interrupts allowed
  369.            1         30 interrupts/second
  370.            2         50 interrupts/second
  371.            3         100 interrupts/second
  372.            4         200 interrupts/second
  373.            5-15      reserved(0)
  374.   Returns: nothing
  375.   Notes:   * This procedure is applicable for the InPort Mouse only.
  376.        * In more than one bit is set in Flags, the lowest order bit
  377.          prevails.
  378. }
  379. PROCEDURE SetPointerPage(Page : word);
  380. { Selects the display page for the mouse pointer.
  381.   Call:    Page = display page
  382.   Returns: nothing
  383.   Note:    * The valid page numbers depend on the current display mode.
  384. }
  385. FUNCTION GetPointerPage : word;
  386. { Returns the current display page for the mouse pointer.
  387. }
  388. PROCEDURE DisableMouseDrvr(VAR Handler : pointer; VAR Err : boolean);
  389. { Disables the mouse driver and returns the address of the previous Int 33H
  390.   handler.
  391.   Call:    nothing
  392.   Returns: Handler = pointer to previous Int 33H handler
  393.        Err     = false if successful, true otherwise
  394.   Notes:   * When this procedure is called, the mouse driver releases any
  395.          interrupt vectors it hase captured OTHER than Int 33H (which may
  396.          be Int 10H, Int 71H, and/or Int 74H).  The application program
  397.          can COMPLETE the process of logically removing the mouse driver
  398.          by restoring the original contents of the Int 33H vector with
  399.          SetIntVec using the pointer returned by the procedure.
  400.        * Also see EnableMouseDrvr.
  401. }
  402. PROCEDURE EnableMouseDrvr;
  403. { Enables the mouse driver and the servicing fo mouse interrupts.
  404.   Call:    nothing
  405.   Returns: nothing
  406.   Note:    * Also see DisableMouseDrvr
  407. }
  408. PROCEDURE ResetMouseDrvr(VAR Buttons : word; VAR Err : boolean);
  409. { Resets the mouse driver and returns driver status.  If the mouse pointer was
  410.   previously visible, is is removed trom the screen, and any presoiusly
  411.   installed user event handlers for mouse events are disabled.
  412.   Call:    nothing
  413.   Returns: Buttons = number of mouse buttons
  414.        Err     = false if mouse support is available, true otherwise
  415.   Note:    * This procedure differ from InitMouse in that there is no
  416.          initialization of the mouse hardware.
  417. }
  418. PROCEDURE SetMouseLang(LangNumber : word);
  419. { Selects the language that will be used by the mouse driver for prompts and
  420.   error messages.
  421.   Call:    LangNumber = language number
  422.             0 = English
  423.             1 = French
  424.             2 = Dutch
  425.             3 = German
  426.             4 = Swedish
  427.             5 = Finnish
  428.             6 = Spanish
  429.             7 = Portuguese
  430.             8 = Italian
  431.   Returns: nothing
  432.   Note:    * This procedure is only functional in international versions of
  433.          the Microsoft Mouse drive.
  434. }
  435. FUNCTION GetMouseLang : word;
  436. { Returns the number of the language that is used by the mouse driver for
  437.   prompts and error messages.
  438.   Call:    nothing
  439.   Returns: language number (see above)
  440.   Note:    * This procedure is only functional in international versions of
  441.          the Microsoft Mouse drive.
  442. }
  443. PROCEDURE GetMouseInfo(VAR MajVer, MinVer, MouseType, IRQ : word);
  444. { Returns the mouse driver version number, mouse type, and the IRQ number of
  445.   the interrupt used by the mouse adapter.
  446.   Call:    nothing
  447.   Returns: MajVer    = major version number (6 for version 6.10, etc.)
  448.        MinVer    = minor version number (10 for version 6.10, etc.)
  449.        MouseType = mouse type
  450.                1 = bus mouse
  451.                2 = serial mouse
  452.                3 = InPort mouse
  453.                4 = PS/2 mouse
  454.                5 = HP mouse
  455.        IRQ       = IRQ number
  456.                0                = PS/2
  457.                2, 3, 4, 5, or 7 = IRQ number
  458. }
  459.  
  460.  
  461. IMPLEMENTATION
  462.  
  463. CONST
  464.   MouseInt = $33;
  465.  
  466. VAR
  467.   Reg : Registers;
  468.  
  469.  
  470. PROCEDURE InitMouse(VAR Buttons : word; VAR Err : boolean);
  471. { Iniialize the mouse driver, if present, and return the number of buttons. }
  472.  
  473. BEGIN
  474.   Reg.AX := 0;
  475.   intr(MouseInt, Reg);
  476.   Buttons := Reg.BX;
  477.   IF (Reg.AX = 0) THEN
  478.     Err := true
  479.   ELSE begin
  480.     Err := false;
  481.     mouseon:=false;
  482.     end
  483. END;
  484.  
  485. procedure showmouse;
  486. begin
  487.   if not mouseon then begin
  488.     reg.ax:=1;
  489.     intr(mouseint,reg);
  490.     mouseon:=true
  491.     end
  492. end;
  493.  
  494. procedure hidemouse;
  495. begin
  496.   if mouseon then begin
  497.     reg.ax:=2;
  498.     intr(mouseint,reg);
  499.     mouseon:=false
  500.     end
  501. end;
  502.  
  503. FUNCTION ButtonPressed(Mask : word) : boolean;
  504.  
  505. BEGIN
  506.   Reg.AX := 3;
  507.   intr(MouseInt, Reg);
  508.   IF (Reg.BX > 0) THEN
  509.     ButtonPressed := true
  510.   ELSE
  511.     ButtonPressed := false;
  512. END;
  513.  
  514. PROCEDURE GetMousePosition(VAR Buttons, Horiz, Vert : word);
  515.  
  516. BEGIN
  517.   Reg.AX := 3;
  518.   intr(MouseInt, Reg);
  519.   Buttons := Reg.BX;
  520.   Horiz := Reg.CX;
  521.   Vert := Reg.DX;
  522. END;
  523.  
  524. FUNCTION MouseIn(x1,y1,x2,y2: word):boolean;
  525. VAR b,x,y: word;
  526. BEGIN
  527.   GetMousePosition(b,x,y);
  528.   MouseIn:=(x>=x1) AND (x<=x2) AND (y>=y1) AND (y<=y2)
  529. END;
  530.  
  531. PROCEDURE SetPointerPosition(Horiz, Vert : word);
  532.  
  533. BEGIN
  534.   Reg.AX := 4;
  535.   Reg.CX := Horiz;
  536.   Reg.DX := Vert;
  537.   intr(MouseInt, Reg);
  538. END;
  539.  
  540. PROCEDURE GetPressInfo(Button : word;
  541.                VAR Stat, Count, Horiz, Vert : word);
  542.  
  543. BEGIN
  544.   Reg.AX := 5;
  545.   Reg.BX := Button;
  546.   intr(MouseInt, Reg);
  547.   Stat := Reg.AX;
  548.   Count := Reg.BX;
  549.   Horiz := Reg.CX;
  550.   Vert := Reg.DX;
  551. END;
  552.  
  553. PROCEDURE GetReleaseInfo(Button : word;
  554.              VAR Stat, Count, Horiz, Vert : word);
  555.  
  556. BEGIN
  557.   Reg.AX := 6;
  558.   Reg.BX := Button;
  559.   intr(MouseInt, Reg);
  560.   Stat := Reg.AX;
  561.   Count := Reg.BX;
  562.   Horiz := Reg.CX;
  563.   Vert := Reg.DX;
  564. END;
  565.  
  566. PROCEDURE SetLimits(HorMin, HorMax, VerMin, VerMax : word);
  567.  
  568. BEGIN
  569.   IF (HorMin > 0) AND (HorMax > 0) THEN
  570.     BEGIN
  571.       Reg.AX := 7;
  572.       Reg.CX := HorMin;
  573.       Reg.DX := HorMax;
  574.       intr(MouseInt, Reg);
  575.     END;
  576.   IF (VerMin > 0) AND (VerMax > 0) THEN
  577.     BEGIN
  578.       Reg.AX := 8;
  579.       Reg.CX := VerMin;
  580.       Reg.DX := VerMax;
  581.       intr(MouseInt, Reg);
  582.     END;
  583. END;
  584.  
  585. PROCEDURE SetPointerShape(Horiz, Vert : word; Buffer : pointer);
  586.  
  587. BEGIN
  588.   Reg.AX := 9;
  589.   Reg.BX := Horiz;
  590.   Reg.CX := Vert;
  591.   Reg.ES := Seg(Buffer);
  592.   Reg.DX := Ofs(Buffer);
  593.   intr(MouseInt, Reg);
  594. END;
  595.  
  596. PROCEDURE SetTextPointer(PtrTyp, AND_Str, XOR_End : word);
  597.  
  598. BEGIN
  599.   Reg.AX := 10;
  600.   Reg.BX := PtrTyp;
  601.   Reg.CX := AND_Str;
  602.   Reg.DX := XOR_End;
  603.   intr(MouseInt, Reg);
  604. END;
  605.  
  606. PROCEDURE GetMotionCount(VAR Horiz, Vert : word);
  607.  
  608. BEGIN
  609.   Reg.AX := 11;
  610.   intr(MouseInt, Reg);
  611.   Horiz := Reg.CX;
  612.   Vert := Reg.DX;
  613. END;
  614.  
  615. PROCEDURE SetEventHandler(EventMask : word; Handler : pointer);
  616.  
  617. BEGIN
  618.   Reg.AX := 12;
  619.   Reg.CX := EventMask;
  620.   Reg.ES := seg(Handler);
  621.   Reg.DX := ofs(Handler);
  622.   intr(MouseInt, Reg);
  623. END;
  624.  
  625. PROCEDURE SetLightPen(On_Off : word);
  626.  
  627. BEGIN
  628.   IF (On_Off = 0) THEN
  629.     Reg.AX := 14
  630.   ELSE
  631.     Reg.AX := 13;
  632.   intr(MouseInt, Reg);
  633. END;
  634.  
  635. PROCEDURE SetPointerExcl(HorMin, VerMin, HorMax, VerMax : word);
  636.  
  637. BEGIN
  638.   Reg.AX := 16;
  639.   Reg.CX := HorMin;
  640.   Reg.SI := HorMax;
  641.   Reg.DX := VerMin;
  642.   Reg.DI := VerMax;
  643.   intr(MouseInt, Reg);
  644. END;
  645.  
  646. PROCEDURE SwapEventHandlers(VAR Mask : word; VAR Buffer : pointer);
  647.  
  648. BEGIN
  649.   Reg.AX := 20;
  650.   Reg.CX := Mask;
  651.   Reg.ES := Seg(Buffer);
  652.   Reg.DX := Ofs(Buffer);
  653.   intr(MouseInt, Reg);
  654.   Mask := Reg.CX;
  655.   Buffer := Ptr(Reg.ES, Reg.DX);
  656. END;
  657.  
  658. FUNCTION GetSaveStateSize : word;
  659.  
  660. BEGIN
  661.   Reg.AX := 21;
  662.   intr(MouseInt, Reg);
  663.   GetSaveStateSize := Reg.BX;
  664. END;
  665.  
  666. PROCEDURE SaveDrvrState(Buffer : pointer);
  667.  
  668. BEGIN
  669.   Reg.AX := 22;
  670.   Reg.ES := Seg(Buffer);
  671.   Reg.DX := Ofs(Buffer);
  672.   intr(MouseInt, Reg);
  673. END;
  674.  
  675. PROCEDURE RestoreDrvrState(Buffer : pointer);
  676.  
  677. BEGIN
  678.   Reg.AX := 23;
  679.   Reg.ES := Seg(Buffer);
  680.   Reg.DX := Ofs(Buffer);
  681.   intr(MouseInt, Reg);
  682. END;
  683.  
  684. PROCEDURE SetAltEventHandler(Mask : word; Handler : pointer; VAR Err: boolean);
  685.  
  686. BEGIN
  687.   Reg.AX := 24;
  688.   Reg.CX := Mask;
  689.   Reg.ES := Seg(Handler);
  690.   Reg.DX := Ofs(Handler);
  691.   intr(MouseInt, Reg);
  692.   IF (Reg.AX = 24) THEN
  693.     Err := false
  694.   ELSE
  695.     Err := true;
  696. END;
  697.  
  698. PROCEDURE GetAltEventAdrs(VAR Mask : word; VAR Handler : pointer;
  699.               VAR Err : boolean);
  700.  
  701. BEGIN
  702.   Reg.AX := 25;
  703.   Reg.CX := Mask;
  704.   intr(MouseInt, Reg);
  705.   IF (Reg.CX > 0) THEN
  706.     BEGIN
  707.       Mask := Reg.CX;
  708.       Handler := Ptr(Reg.ES, Reg.DX);
  709.       Err := false;
  710.     END
  711.   ELSE
  712.     Err := true;
  713. END;
  714.  
  715. PROCEDURE SetMouseSense(Horiz, Vert, Double : word);
  716.  
  717. BEGIN
  718.   Reg.AX := 26;
  719.   Reg.BX := Horiz;
  720.   Reg.CX := Vert;
  721.   Reg.DX := Double;
  722.   intr(MouseInt, Reg);
  723. END;
  724.  
  725. PROCEDURE GetMouseSense(VAR Horiz, Vert, Double : word);
  726.  
  727. BEGIN
  728.   Reg.AX := 27;
  729.   intr(MouseInt, Reg);
  730.   Horiz := Reg.BX;
  731.   Vert := Reg.CX;
  732.   Double := Reg.DX;
  733. END;
  734.  
  735. PROCEDURE SetMouseIntr(Flags : word);
  736.  
  737. BEGIN
  738.   Reg.AX := 28;
  739.   Reg.BX := Flags;
  740.   intr(MouseInt, Reg);
  741. END;
  742.  
  743. PROCEDURE SetPointerPage(Page : word);
  744.  
  745. BEGIN
  746.   Reg.AX := 29;
  747.   Reg.BX := Page;
  748.   intr(MouseInt, Reg);
  749. END;
  750.  
  751. FUNCTION GetPointerPage : word;
  752.  
  753. BEGIN
  754.   Reg.AX := 30;
  755.   intr(MouseInt, Reg);
  756.   GetPointerPage := Reg.BX;
  757. END;
  758.  
  759. PROCEDURE DisableMouseDrvr(VAR Handler : pointer; VAR Err : boolean);
  760.  
  761. BEGIN
  762.   Reg.AX := 31;
  763.   intr(MouseInt, Reg);
  764.   IF (Reg.AX = 31) THEN
  765.     BEGIN
  766.       Handler := ptr(Reg.ES, Reg.DX);
  767.       Err := false;
  768.     END
  769.   ELSE
  770.     Err := true;
  771. END;
  772.  
  773. PROCEDURE EnableMouseDrvr;
  774.  
  775. BEGIN
  776.   Reg.AX := 32;
  777.   intr(MouseInt, Reg);
  778. END;
  779.  
  780. PROCEDURE ResetMouseDrvr(VAR Buttons : word; VAR Err : boolean);
  781.  
  782. BEGIN
  783.   Reg.AX := 33;
  784.   intr(MouseInt, Reg);
  785.   IF (Reg.AX = $FFFF) THEN
  786.     BEGIN
  787.       Buttons := Reg.BX;
  788.       Err := false;
  789.     END
  790.   ELSE
  791.     Err := true;
  792. END;
  793.  
  794. PROCEDURE SetMouseLang(LangNumber : word);
  795.  
  796. BEGIN
  797.   Reg.AX := 34;
  798.   Reg.BX := LangNumber;
  799.   intr(MouseInt, Reg);
  800. END;
  801.  
  802. FUNCTION GetMouseLang : word;
  803.  
  804. BEGIN
  805.   Reg.AX := 35;
  806.   intr(MouseInt, Reg);
  807.   GetMouseLang := Reg.BX;
  808. END;
  809.  
  810. PROCEDURE GetMouseInfo(VAR MajVer, MinVer, MouseType, IRQ : word);
  811.  
  812. BEGIN
  813.   Reg.AX := 36;
  814.   intr(MouseInt, Reg);
  815.   MajVer := Reg.BH;
  816.   MinVer := Reg.BL;
  817.   MouseType := Reg.CH;
  818.   IRQ := Reg.CL;
  819. END;
  820.  
  821. END.